<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>Cookie购物车</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="购物、cookie">
	<meta http-equiv="description" content="cookie购物车">
	<script src="js/jquery-1.4.2.js" type="text/javascript" language="javascript"></script>
	<script type="text/javascript" language="javascript">
		
		$(function(){
			
			$("tr td a").click(function(){
			
				$.post("CookieShopCar", 
				       { type: "2" ,
				         sid:$(this).next().val()
				       },
						
					   function(data){
							     
							var obj = eval(data);
							var buys = "";
							for(i in obj){
							    buys += obj[i].name+","+obj[i].price+"\r\n";
							    
							}
							$("#scar").val(buys);     
				       });
			
			});
			
		});
	
	</script>
	
  </head>
  
  <body>
    <div>
    	欢迎<span style="color: red;">${ uName }</span>来到惊涛骇浪购物网
    </div>
 	<table border="1">
 		<tr>
 			<th colspan="4" align="center">货物列表</th>
 		</tr>
 		<tr>
 			<th>序号</th>
 			<th>商品</th>
 			<th>价格</th>
 			<th>操作</th>
 		</tr>
 		<c:forEach items="${ shops }" var="sp" varStatus="id">
 			<tr>
	 			<td>${ id.index + 1 }</td>
	 			<td>${ sp.sname }</td>
	 			<td>${ sp.sprice }元</td>
	 			<td>
	 				<a href="javascript:void(0)" id="buyShop" >购买</a>
	 				<input type="hidden" value="${ sp.sid }"/>
	 			</td>
 			</tr>
 		</c:forEach>
 	</table>
 	<div style="color: blue;font-weight: bolder;">
 		我的购物车
 	</div>
 	<textarea rows="50" cols="20" id="scar"></textarea>
  </body>
</html>
